FROM golang:1.12-alpine AS build

WORKDIR /go/src/app
COPY . .

ENV GO111MODULE on
ENV GOPROXY https://mirrors.aliyun.com/goproxy/

RUN go mod vendor
RUN go install -v ./...

# images
FROM ubuntu:latest
ENV DEBIAN_FRONTEND=noninteractive

MAINTAINER zhouseyi "zsy1988cool@163.com"
RUN sed -i s@/archive.ubuntu.com/@/mirrors.aliyun.com/@g /etc/apt/sources.list
RUN apt-get clean
RUN apt-get update

WORKDIR /app
COPY --from=build /go/src/app .
COPY --from=build /go/bin/main /usr/local/bin


# install packages
RUN chmod 777 /tmp \
	&& apt-get update

# timezone environment
ENV TZ Asia/Shanghai

# language environment
ENV LC_ALL C.UTF-8
ENV LANG C.UTF-8

# backend port
EXPOSE 38000

# start backend
CMD ["main"]
